package com.bana.sys.controller;

import com.bana.sys.code.FileResult;
import com.bana.sys.service.FileService;
import com.bana.sys.utils.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;


@RestController
@RequestMapping(value = "/file",method = RequestMethod.POST)
public class FileController {

    @Resource
    private FileService fileService;

    @RequestMapping(value = "/upload.do", method = RequestMethod.POST)
    public ActionResult upload(@RequestParam(value = "file") MultipartFile multipartFile) throws IOException {

        String fileName= fileService.saveFile(multipartFile);
        ActionResult actionResult=new ActionResult();
        actionResult.setName(fileName);
        actionResult.setCzjg(FileResult.Success);
        return actionResult;
    }

}
